package com.bgs.eat.chat.controller;

import com.bgs.eat.chat.service.ChatRecordService;
import com.bgs.eat.config.CommonResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName ChatRecordController
 * @Description TODO 公共聊天室（用户app--我的）
 * @Author G胖
 * @Date 2022-10-17 下午 02:35
 **/
@RestController
@CrossOrigin
@RequestMapping("/chatRecord")
public class ChatRecordController {

    @Resource
    ChatRecordService chatRecordService;

    /**
    * @Author G胖
    * @Description 查询用户和商家之间的历史记录
    * @Date 2022-10-19 下午 02:33
    * @Return com.bgs.eat.config.CommonResult

    */
    @GetMapping("/getChatRecord")
    public CommonResult getChatRecord(Integer toId,Integer fromId){
        return  CommonResult.ok(chatRecordService.getChatRecord(toId,fromId));
    }

    /**
    * @Author G胖
    * @Description 查询商家给那些用户发送了消息
    * @Date 2022-10-24 下午 01:40
    * @Return com.bgs.eat.config.CommonResult

    */
    @GetMapping("/getUserChatRecord")
    public CommonResult getUserChatRecord(Integer toId){
        return CommonResult.ok(chatRecordService.getUserChatRecord(toId));
    }

    /**
    * @Author G胖
    * @Description 查询用户给哪些商家发送了消息
    * @Date 2022-10-25 上午 08:53
    * @Return com.bgs.eat.config.CommonResult

    */
    @GetMapping("/getBusinessChatRecord")
    public CommonResult getBusinessChatRecord(Integer toId){
        return CommonResult.ok(chatRecordService.getBusinessChatRecord(toId));
    }
}
